//
//  XqEnterTableViewCell.m
//  Koala_Fm
//
//  Created by dllo on 16/1/26.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "XqEnterTableViewCell.h"

@implementation XqEnterTableViewCell

- (void)dealloc
{
    [_avatarImage release];
    [_genderImage release];
    [_nameLable release];
    [_commLable release];
    [_upLable release];
    [_imagOne release];
    [super dealloc];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        //
        self.avatarImage = [[UIImageView alloc]init];
//        _avatarImage.backgroundColor = [UIColor redColor];
        [self.contentView addSubview:_avatarImage];
        [_avatarImage release];
        // 切圆
        _avatarImage.layer.cornerRadius = 35;
        _avatarImage.clipsToBounds = YES;
        //
        self.genderImage = [[UIImageView alloc]init];
//        self.genderLable.backgroundColor =[UIColor yellowColor];
        [self.contentView addSubview:_genderImage];
        [_genderImage release];
        //
        self.nameLable = [[UILabel alloc]init];
//        self.nameLable.backgroundColor = [UIColor blueColor];
        [self.contentView addSubview:_nameLable];
        [_nameLable release];
        //
        

        self.commLable = [[UILabel alloc]init];
//        self.nameLable.backgroundColor = [UIColor greenColor];
        self.commLable.numberOfLines = 0;
        [self.contentView addSubview:_commLable];
        [_commLable release];
        //
        self.upLable = [[UILabel alloc]init];
//        self.upLable.backgroundColor = [UIColor cyanColor];
        [self.contentView addSubview:_upLable];
        [_upLable release];
        //
        self.imagOne = [[UIImageView alloc]init];
//        self.imagOne.backgroundColor = [UIColor redColor];
        [self.contentView addSubview:_imagOne];
        [_imagOne release];
    }
    return self;
}

-(void)layoutSubviews{
    [super layoutSubviews];
    _avatarImage.frame =CGRectMake(10, 5, 70, 70);
    _genderImage.frame =CGRectMake(80, 5, 20, 20);
    _nameLable.frame = CGRectMake(100, 5, 250, 20);
    CGFloat h = [[self class]heightWithText:_commLable.text];
    _commLable.frame = CGRectMake(10, 85, self.contentView.frame.size.width - 10, h);
    
    _upLable.frame = CGRectMake(self.contentView.frame.size.width - 50, 30, 30, 30);
    _imagOne.frame = CGRectMake(self.contentView.frame.size.width - 50, 5, 30, 30);
    
}
 //文字自适应高度
+(CGFloat)heightWithText:(NSString *)text {
    NSDictionary *dic = @{NSFontAttributeName:[UIFont systemFontOfSize:17]};
    CGSize size = CGSizeMake(355, 1000);
    CGRect rect = [text boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
    return rect.size.height;
}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
